<template>
  <el-form :inline="true" :model="form">
    <el-form-item label="教室号">
      <el-input v-model="form.roomid" placeholder="教室号"></el-input>
    </el-form-item>
    <el-form-item label="请输入学工号/教职工号">
      <el-input v-model="form.stdid" placeholder="学工号/教职工号"></el-input>
    </el-form-item>
    <el-form-item label="请输入姓名">
      <el-input v-model="form.name" placeholder="姓名"></el-input>
    </el-form-item>
    <el-form-item label="请输入电话">
      <el-input v-model="form.phone" placeholder="电话"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="update">确认</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import request from "@/utils/request";

export default {
  name: "ServiceRoom",
  data() {
    return {
      form: {}
    }
  },
  created() {
    const roomid = this.$route.query.roomid
    request.get('/room/' + roomid).then(res => {
      this.form = res.data
    })
    const stdid = form.stdid
    request.get('/user/' + name + phone).then(res => {
      this.form = res.data
    })
  },
  // created2() {
  //   const stdid=this.$route.query.stdid
  //   request.get('/user/' + name + phone).then(res =>{
  //     this.form = res.data
  //   })
  // },
  methods: {
    update() {
      request.post('/record/add', this.form).then(res => {
        if (res.code === '200') {
          this.$notify.success('新增一条记录')
        } else {
          this.$notify.error('res.msg')
        }
        request.put('/room/update', this.form).then(res => {
          if (res.code === '200') {
            this.$notify.success('执行成功')
            this.$router.push("/borrow")
          } else {
            this.$notify.error(res.msg)
          }


        })
      })
    }
  }
}
</script>